<template>
	<view class="cont_box">
		<view class="desc">
			购买积分可用于视频下载，高清导出和优先生成等服务，积分永久有效
		</view>
		<view class="title">
			选择充值金额
		</view>
		<view class="list">
			<view class="list_item" v-for="item in recharge" :key="item.id" :class="active==item.id?'active':''"
				@click="activechange(item.id,item.pointsPrice)">
				<view class="iconfont icon-duihao2" v-if="active==item.id">
				</view>
				<view class="item">
					<view class="item_points">
						{{item.pointsBase}}积分
					</view>
					<view class="item_desc">
						赠送{{item.pointsExtra}}积分,共{{item.pointsBase+item.pointsExtra}}积分
					</view>
				</view>
				<view class="item_amount">
					¥{{item.pointsPrice}}.00
				</view>
			</view>
		</view>
		<view class="title">
			选择支付方式
		</view>
		<view class="wxchat">
			<view class="wxchat_item">
				<view class="iconfont icon-weixin">

				</view>
				<view class="wxchat_title">
					微信支付
				</view>
			</view>
			<view class="iconfont icon-yuandian">

			</view>
		</view>
		<view class="notice">
			充值须知
		</view>
		<view class="notice_desc">
			积分充值后永久有效，可用于所有付费服务
		</view>
		<view class="notice_desc">
			充值成功后积分将立即到账，可在“我的积分”中查看
		</view>
		<view class="total">
			<view class="total_title">
				总计：
			</view>
			<view class="total_desc">
				¥{{pointsPricestr}}.00
			</view>
		</view>
		<view class="submit_sub" @click="submit">
			确认充值
		</view>
		<u-toast ref="uToast"></u-toast>
	</view>
</template>
<script>
	export default {
		data() {
			return {
				active: '',
				recharge: [],
				pointsPricestr: "0"
			};
		},
		components: {},
		onload() {

		},
		mounted() {
			this.pointsPrice()
		},
		watch: {

		},
		methods: {
			//充值价格列表
			pointsPrice() {
				this.$request(`/points/getPointsPrice`, 'get').then(
					res => {
						this.recharge = res.data.data

					})
			},
			activechange(e, price) {
				this.pointsPricestr = price
				this.active = e
			},
			submit() {

				const that = this
				if (!this.active) {
					this.$refs.uToast.show({
						type: "error",
						message: '请选择充值金额',
						iconUrl: 'https://cdn.uviewui.com/uview/demo/toast/top.png'
					})
					return
				}
				this.$request(`/points/pay/${this.active}`, 'get').then(
					res => {
						if (res.data.data) {
							that.$refs.uToast.show({
								type: "success",
								message: '充值成功',
							})
							setTimeout(() => {
							  uni.reLaunch({
							    url: '/subpackage/points/points_consume'
							  });
							}, 1000);  // 1000毫秒即1秒
						}
					})
			}
		}
	};
</script>

<style scoped lang="scss">
	.cont_box {
		padding: 15px;

		.desc {
			font-size: 24rpx;
			color: #738093;
		}

		.title {
			margin-top: 30px;
			font-size: 30rpx;
			font-weight: 600;
		}

		.list {

			.list_item {
				display: flex;
				justify-content: space-between;
				align-items: center;
				padding: 10px;
				border: 1px solid #ededee;
				border-radius: 10px;
				margin-top: 10px;
				position: relative;

				.icon-duihao2 {
					right: -5px;
					top: -5px;
					font-size: 35rpx;
					position: absolute;
					color: #fa934d;
				}

				.item {

					.item_points {
						font-size: 29rpx;
						font-weight: 600;
						margin-bottom: 5px;
					}

					.item_desc {
						font-size: 24rpx;
						color: #738093;
					}
				}

				.item_amount {
					font-size: 32rpx;
					font-weight: 600;
				}
			}

			.active {
				border: 2px solid #fa934d;
				background-color: #fff7ed;

			}
		}

		.wxchat {
			height: 60px;
			padding: 0 20px;
			border: 1px solid #ededee;
			border-radius: 10px;
			margin-top: 10px;
			display: flex;
			align-items: center;
			justify-content: space-between;

			.wxchat_item {
				display: flex;
				align-items: center;

				.icon-weixin {
					color: #22c55e;
					font-size: 40rpx;
					margin-right: 10px;
				}

				.wxchat_title {
					font-weight: 600;
				}

			}

			.icon-yuandian {
				color: #f97316;
				font-size: 36rpx;
			}
		}

		.notice {
			margin-top: 10px;
			font-size: 28rpx;
			color: #738093;
			font-weight: 600;
		}

		.notice_desc {
			margin-top: 5px;
			font-size: 24rpx;
			color: #738093;
		}

		.total {
			display: flex;
			margin: 10px 0;

			justify-content: space-between;

			.total_title {
				font-size: 28rpx;
				color: #738093;
				font-weight: 600;
			}

			.total_desc {
				font-size: 32rpx;
				font-weight: 600;
			}
		}

		.submit_sub {
			height: 50px;
			background-color: #f97316;
			line-height: 50px;
			border-radius: 10px;
			text-align: center;
			font-weight: 600;
			color: #fff;
		}
	}
</style>